var units = require('../db')
var express = require('express')
var router = express.Router()
router.post('/searchlist', (req, res) => {
    var { cat_code, cat_desc } = req.body;

    // console.log(cat_code, 'catecode');
    var sqllist = "select * from test_sell_thru where cat_code='" + cat_code + "' and organisation_no=10"

    // console.log(sqllist);
    units.sql(sqllist, function(err, result) {
        let msg = ''
        let code = -1
        if (err) {
            msg = err
            code = -1
        } else {
            msg = '成功'
            code = 0
        }
        // console.log('data :', result)
        res.json({
            code: code,
            data: result.recordset,
            msg: msg
        })
    })
})
module.exports = router